package org.example.curriculum_design_6_16.mapper;

import org.apache.ibatis.annotations.*;
import org.example.curriculum_design_6_16.entity.pojo.IntellectualProperty;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import javax.mail.MailSessionDefinition;
import java.util.List;

/**
* @author 郑凯
* @description 针对表【intellectual_property(知识产权记录表)】的数据库操作Mapper
* @createDate 2025-06-23 09:02:07
* @Entity org.example.curriculum_design_6_16.entity.pojo.IntellectualProperty
*/
@Mapper
public interface IntellectualPropertyMapper extends BaseMapper<IntellectualProperty> {
    @Insert("INSERT INTO intellectual_property(student_id, ip_type, name, application_number, application_date, " +
            "ip_status, authorization_number, authorization_date, certificate_number, is_team_leader, team_size, " +
            "score, proof_url, review_status, review_comment, academic_year) " +
            "VALUES(#{studentId}, #{ipType}, #{name}, #{applicationNumber}, #{applicationDate}, #{ipStatus}, " +
            "#{authorizationNumber}, #{authorizationDate}, #{certificateNumber}, #{isTeamLeader}, #{teamSize}, " +
            "#{score}, #{proofUrl}, #{reviewStatus}, #{reviewComment}, #{academicYear})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertIntellectualProperty(IntellectualProperty intellectualProperty);

    @Update("UPDATE intellectual_property SET " +
            "student_id=#{studentId}, ip_type=#{ipType}, name=#{name}, application_number=#{applicationNumber}, " +
            "application_date=#{applicationDate}, ip_status=#{ipStatus}, authorization_number=#{authorizationNumber}, " +
            "authorization_date=#{authorizationDate}, certificate_number=#{certificateNumber}, " +
            "is_team_leader=#{isTeamLeader}, team_size=#{teamSize}, score=#{score}, proof_url=#{proofUrl}, " +
            "review_status=#{reviewStatus}, review_comment=#{reviewComment}, academic_year=#{academicYear} " +
            "WHERE id=#{id}")
    int updateIntellectualProperty(IntellectualProperty intellectualProperty);

    @Delete("DELETE FROM intellectual_property WHERE id=#{id}")
    int deleteIntellectualPropertyById(Integer id);

    @Select("SELECT * FROM intellectual_property WHERE id=#{id}")
    IntellectualProperty getIntellectualPropertyById(Integer id);

    @Select("SELECT * FROM intellectual_property WHERE student_id=#{studentId}")
    List<IntellectualProperty> getIntellectualPropertiesByStudentId(String studentId);

    @Select("SELECT * FROM intellectual_property WHERE student_id=#{studentId} AND academic_year=#{academicYear}")
    List<IntellectualProperty> getIntellectualPropertiesByStudentIdAndYear(@Param("studentId") String studentId, @Param("academicYear") String academicYear);

    @Select("SELECT * FROM intellectual_property")
    List<IntellectualProperty> getAllIntellectualProperties();
}




